local thbattle__bayunlan_jizhi = fk.CreateSkill {

  name = "thbattle__bayunlan_jizhi",

  tags = {  },

}



thbattle__bayunlan_jizhi:addEffect(fk.CardEffectFinished, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(thbattle__bayunlan_jizhi.name) and player.phase == Player.NotActive and
        player:usedSkillTimes(thbattle__bayunlan_jizhi.name, Player.HistoryRound) == 0 and data.card and data.card.type == Card.TypeTrick
        and data.card.sub_type ~= Card.SubtypeDelayedTrick and not player:isNude() and 
        ( data.to and not player:isProhibited(data.to,data.card))
        and ((data.responseToEvent and data.responseToEvent.isCancellOut==false)or data.responseToEvent==nil )
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askForSkillInvoke(player, thbattle__bayunlan_jizhi.name, nil, "#thbattle__bayunlan_jizhi:" .. target.id .. "::" .. data.card:toLogString()) then
      local target_cids = room:askForDiscard(player, 1, 1, true, thbattle__bayunlan_jizhi.name, true, ".",
        "#thbattle__bayunlan_jizhi-discard:" .. target.id .. "::" .. data.card:toLogString())
      return #target_cids > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card=Fk:cloneCard(data.card.name,data.card.suit,data.card.number)
    room:useCard({
      from = player,
      tos = {  target  },
      card = card ,
    })
  end,
})

return thbattle__bayunlan_jizhi